﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace ENG.EngStartQueue
{
  public partial class FrmCategories : Form
  {
    public FrmCategories()
    {
      InitializeComponent();
    }

    private void FrmCategories_Load(object sender, EventArgs e)
    {
      var cats = PerformanceCounterCategory.GetCategories();

      foreach (var fItem in cats)
      {
        lstCat.Items.Add(fItem.CategoryName);
      } // foreach (var fItem in cats)
    }

    private void lstCat_SelectedIndexChanged(object sender, EventArgs e)
    {
      var cat = new PerformanceCounterCategory(lstCat.Text);
      var insts = cat.GetInstanceNames();
      PerformanceCounter[] counts;

      if (insts.Length > 0)
        counts = cat.GetCounters(insts[0]);
      else
        counts = cat.GetCounters();

      lstCount.Items.Clear();
      foreach (var fItem in counts)
      {
        lstCount.Items.Add(fItem.CounterName);
      } // foreach (var fItem in counts)

      lstInst.Items.Clear();
      foreach (var fItem in insts)
      {
        lstInst.Items.Add(fItem);
      } // foreach (var fItem in intsts)
    }

    private void btnCopyCat_Click(object sender, EventArgs e)
    {
      Clipboard.SetText(lstCat.Text);
    }

    private void btnCopyCount_Click(object sender, EventArgs e)
    {
      Clipboard.SetText(lstCount.Text);
    }

    private void btnCopyInst_Click(object sender, EventArgs e)
    {
      Clipboard.SetText(lstInst.Text);
    }
  }
}
